package animation;

import java.awt.Color;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;

import graphics.MaxGraphics;
import structure.*;
import util.LinAlg;
import util.Point;

public class Explosion extends SObject {
	
	private double radius, maxRadius;
	
	public Explosion(Point p, Point vel, int radius, int maxRadius) {
		super(p);
		this.maxRadius = maxRadius;
		this.radius = radius;
		this.vel = new Point(LinAlg.scale(LinAlg.unitVector(vel), 50));
	}
	
	@Override
	public void draw(MaxGraphics g) {
		g.setColor(Color.red);
		g.fillOval(getX(), getY(), radius, radius);
	}
	
	public void update() {
		radius += 1;
		if (radius > maxRadius) {
			flag();
		}
		super.update();
	}

	public Shape[] getShape() {
		Shape[] s = {  new Ellipse2D.Double(getX() - radius, getY() - radius, radius * 2, radius * 2) };
		return s;
	}
	
	@Override
	public void collide(SObject s) {
		
		
	}

	@Override
	public double getRadius() {
		// TODO Auto-generated method stub
		return radius;
	}

	@Override
	public String toString() {
		return "Explosion " + getX() + " " + getY() + " " + radius;
	}

	public double getMass() {
		return 0;
	}
}
